package singleton;

/**
 * @author Europa
 * @create 2020-05-28 0:18
 */
public class Singleton {

    private Singleton() {

    }

    private static volatile Singleton singleton;

    public static Singleton getSingleton() {
        if (singleton == null) {
            //貌似用Lock也能实现
            synchronized (Singleton.class) {
                if (singleton == null) {
                    singleton = new Singleton();
                }
            }
        }
        return singleton;
    }
}
